Skip to content

[Lens] Set better opinionated per chart type default behavior for "include empty rows"#263521

Draft
awahab07 wants to merge 31 commits into
elastic:mainfrom
awahab07:254889_Lens_Disable-switch-off_include-empty-rows_config-option-for-some-charts
Draft

[Lens] Set better opinionated per chart type default behavior for "include empty rows"#263521
awahab07 wants to merge 31 commits into
elastic:mainfrom
awahab07:254889_Lens_Disable-switch-off_include-empty-rows_config-option-for-some-charts

Conversation

@awahab07
Copy link
Copy Markdown
Contributor

@awahab07 awahab07 commented Apr 15, 2026

Closes #254889

Summary

  • Introduce a shared VisualizationDatasourceDefaults port in @kbn/lens-common so Lens visualizations can declare datasource-level defaults alongside their dimension groups.
  • Use that port to default date histogram includeEmptyRows off for new Bar, Heatmap, Pie, Treemap, Metric, Tag cloud, Waffle, and Mosaic charts, while keeping Datatable defaults on and preserving explicit saved/API values.
  • Apply the same defaults consistently across Lens editor flows, subtype switches, chart switches, suggestions, suggestions API subtype selection, and embeddable config-builder/API ingress.
Before
After
254889-include-empty-rows-before.mov
254889-include-empty-rows-switched-off-after.mov

What changed

  • Added shared helpers in @kbn/lens-common to:
    • resolve visualization-specific datasource defaults from visualization type/subtype/state
    • apply those defaults when creating column params
    • normalize existing datasource state when a caller needs an explicit chart-specific override
  • Added XY and partition chart-family helpers so Bar-family XY subtypes and supported partition shapes share a single source of truth for includeEmptyRows defaults.
  • Extended VisualizationDimensionGroupConfig with datasourceDefaults so visualizations can pass datasource defaults directly to the dimension editor instead of routing them through ad hoc editor props.
  • Wired datasource defaults into Datatable, Heatmap, Metric, Tag cloud, Partition, and XY visualization configs, including Metric trendline groups.
  • Updated form-based datasource column creation/replacement to backfill visualization defaults when building or replacing bucket dimensions.
  • Updated chart switch and suggestion flows to normalize datasource state with overwriteExisting: true when the user switches to a chart or subtype whose default should take precedence.
  • Updated XY subtype switching so changing a layer between Bar/Line/Area updates both visualization state and the underlying datasource state for the selected layer.
  • Updated Lens suggestions API subtype selection to reapply datasource defaults after switchVisualizationType.
  • Updated the embeddable config builder and API transforms so omitted include_empty_rows stays omitted at schema/transform boundaries and chart-specific defaults are applied later from visualization context instead of being forced to true.
  • Updated XY config-builder output so the visualization state's preferredSeriesType matches the first series layer subtype, keeping builder output aligned with shared XY default resolution.
  • Fixed the date histogram interval editor to resync its local interval input when the column interval changes externally, avoiding the repeated update loop seen in multi-layer charts.

Behavior

  • New charts get the chart-specific default for includeEmptyRows.
  • Existing saved charts keep their current includeEmptyRows value when it is already explicit.
  • API configs that omit include_empty_rows now inherit the target chart's default instead of always becoming true.
  • Switching a chart or subtype to a Bar-family visualization explicitly reapplies the Bar default, even if the previous chart state had a different value.
  • Layer-scoped subtype switches only rewrite the affected layer's datasource state instead of touching sibling layers in mixed charts.

How to test

  1. Have Kibana ready and create a dashboard and a new Lens visualization.
  2. Confirm the following charts and expected state
    • Bar, Heatmap, Pie, Treemap, Metric, Tag cloud, Waffle, Mosaic: Include empty rows off
    • Datatable: Include empty rows on

Edgy cases

  • In a multi-layer XY chart, switch only one layer's subtype and confirm the sibling layer keeps its own includeEmptyRows state.
  • Build or import Lens API configs that omit include_empty_rows and confirm the resulting Lens state picks up the target chart default rather than forcing true.

Notes

  • line and area handling remains follow-up work for #256104

@elasticmachine
Copy link
Copy Markdown
Contributor

elasticmachine commented Apr 15, 2026

🤖 Jobs for this PR can be triggered through checkboxes. 🚧

ℹ️ To trigger the CI, please tick the checkbox below 👇

  • Click to trigger kibana-pull-request for this PR!
  • Click to trigger kibana-deploy-project-from-pr for this PR!
  • Click to trigger kibana-deploy-cloud-from-pr for this PR!
  • Click to trigger kibana-entity-store-performance-from-pr for this PR!
  • Click to trigger kibana-storybooks-from-pr for this PR!

awahab07 and others added 25 commits April 20, 2026 18:22
…witch-off_include-empty-rows_config-option-for-some-charts
…witch-off_include-empty-rows_config-option-for-some-charts
…witch-off_include-empty-rows_config-option-for-some-charts
…witch-off_include-empty-rows_config-option-for-some-charts
…witch-off_include-empty-rows_config-option-for-some-charts
…witch-off_include-empty-rows_config-option-for-some-charts
…witch-off_include-empty-rows_config-option-for-some-charts
…witch-off_include-empty-rows_config-option-for-some-charts
…witch-off_include-empty-rows_config-option-for-some-charts
…witch-off_include-empty-rows_config-option-for-some-charts
@kibanamachine
Copy link
Copy Markdown
Contributor

kibanamachine commented Jun 1, 2026

💔 Build Failed

Failed CI Steps

Test Failures

  • [job] [logs] FTR Configs #173 / lens app - group 1 Inspector should allow switch between table page
  • [job] [logs] FTR Configs #173 / lens app - group 1 Inspector should allow switch between table page
  • [job] [logs] FTR Configs #176 / lens app - group 2 lens table on dashboard should sort a table by column in dashboard edit mode
  • [job] [logs] FTR Configs #176 / lens app - group 2 lens table on dashboard should sort a table by column in dashboard edit mode
  • [job] [logs] FTR Configs #212 / lens app - group 6 lens metric secondary should disable collapse by when the primary metric is not numeric
  • [job] [logs] FTR Configs #212 / lens app - group 6 lens metric secondary should disable collapse by when the primary metric is not numeric
  • [job] [logs] FTR Configs #28 / lens serverless - group 1 - subgroup 1 lens smokescreen tests should create a pie chart and switch to datatable
  • [job] [logs] FTR Configs #58 / lens serverless - group 1 - subgroup 1 lens smokescreen tests should create a pie chart and switch to datatable
  • [job] [logs] FTR Configs #62 / lens serverless - group 1 - subgroup 1 lens smokescreen tests should create a pie chart and switch to datatable
  • [job] [logs] FTR Configs #28 / lens serverless - group 1 - subgroup 1 lens smokescreen tests should create a pie chart and switch to datatable
  • [job] [logs] FTR Configs #62 / lens serverless - group 1 - subgroup 1 lens smokescreen tests should create a pie chart and switch to datatable
  • [job] [logs] FTR Configs #58 / lens serverless - group 1 - subgroup 1 lens smokescreen tests should create a pie chart and switch to datatable
  • [job] [logs] FTR Configs #145 / Sanity checks lens app lens smokescreen tests should create a pie chart and switch to datatable
  • [job] [logs] FTR Configs #147 / Sanity checks lens app lens smokescreen tests should create a pie chart and switch to datatable
  • [job] [logs] FTR Configs #186 / Sanity checks lens app lens smokescreen tests should create a pie chart and switch to datatable
  • [job] [logs] FTR Configs #190 / Sanity checks lens app lens smokescreen tests should create a pie chart and switch to datatable
  • [job] [logs] FTR Configs #190 / Sanity checks lens app lens smokescreen tests should create a pie chart and switch to datatable
  • [job] [logs] FTR Configs #147 / Sanity checks lens app lens smokescreen tests should create a pie chart and switch to datatable
  • [job] [logs] FTR Configs #186 / Sanity checks lens app lens smokescreen tests should create a pie chart and switch to datatable
  • [job] [logs] FTR Configs #145 / Sanity checks lens app lens smokescreen tests should create a pie chart and switch to datatable

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
agentBuilder 1962 1965 +3
agentBuilderDashboards 600 603 +3
cases 2075 2078 +3
dashboard 1097 1100 +3
discover 2132 2135 +3
infra 1916 1919 +3
lens 1814 1817 +3
ml 4350 4353 +3
observability 1821 1824 +3
observabilityAIAssistantApp 856 859 +3
triggersActionsUi 1866 1869 +3
unifiedDocViewer 985 988 +3
visTypePie 166 169 +3
visTypeTimeseries 528 531 +3
visTypeXy 197 200 +3
visualizations 779 782 +3
total +48

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
agentBuilder 1.9MB 1.9MB +2.7KB
agentBuilderDashboards 394.0KB 396.8KB +2.7KB
cases 2.4MB 2.4MB +2.7KB
dashboard 1.1MB 1.1MB +2.7KB
discover 1.9MB 1.9MB +2.7KB
infra 1.5MB 1.5MB +2.7KB
lens 2.1MB 2.1MB +5.1KB
observability 2.1MB 2.1MB +2.7KB
observabilityAIAssistantApp 666.1KB 668.8KB +2.8KB
unifiedDocViewer 686.2KB 688.9KB +2.7KB
visTypeTimeseries 441.0KB 441.0KB +5.0B
total +29.7KB

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
lens 88.2KB 88.2KB -2.0B
observability 102.1KB 102.1KB +1.0B
unifiedDocViewer 14.7KB 14.7KB +1.0B
total -0.0B

History

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Lens] Disable/switch off "include empty rows" config option for some charts

3 participants